package com.breaking.second.utils;

import android.view.Window;

import androidx.core.view.WindowCompat;
import androidx.core.view.WindowInsetsControllerCompat;

//状态栏工具类
public class StatusBarUtil {
    public static void setDecorFitsSystemWindows(Window window, boolean decorFitsSystemWindows) {
        //关键代码,沉浸
        WindowCompat.setDecorFitsSystemWindows(window, decorFitsSystemWindows);
    }

    /**
     * @param color 状态栏颜色
     * @param is    状态栏字体颜色
     */
    public static void setBarColor(Window window, int color, boolean is) {
        window.setStatusBarColor(color);
        window.setNavigationBarColor(color);
        window.setNavigationBarDividerColor(color);
        WindowInsetsControllerCompat controller = WindowCompat.getInsetsController(window, window.getDecorView());
        controller.setAppearanceLightStatusBars(is);
    }

    public static void setAppearanceLightStatusBars(Window window,boolean is) {
        WindowInsetsControllerCompat controller = WindowCompat.getInsetsController(window, window.getDecorView());
        controller.setAppearanceLightStatusBars(is);
    }

}
